// Ray Bai
// Simple Input and Output in C++
// 5/31/2011

#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
    double value1, value2, value3;
    
    ifstream infile("C:\\Users\\Ray Bai\\Programming\\simpleinput.txt"); 
    if(!infile) {
                cout << "Intput file could not be opened" << endl;
                }
                else
                {
                    cout << "Output file successfully created.\n";
                }
    ofstream outfile("C:\\Users\\Ray Bai\\Programming\\simpleoutput.txt");
    if(!outfile) {
                 cerr << "Output file could not be opened" << endl;
                 exit(1);
                  }
                
    infile >> value1 >> value2 >> value3;

    double sum, product, average;
    sum = value1 + value2 + value3;
    product = value1 * value2 * value3;
    average = sum / 3;

    outfile << "Doubles: " << value1 << " " << value2 << " " << value3;
    outfile << setprecision(4) << fixed << endl << endl;
    outfile << "Sum = " << sum << endl;
    outfile << "Product = " << product << endl; 
    outfile << "Average = " << average << endl; 
    
    system("pause");
    return 0;
}
